// ALIBEMotor.cpp file
#include <Arduino.h>
#include <ALIBEMotor.h>

	ALIBEMotor::ALIBEMotor(){
	//
    // set the data rate for the TX2 port @ 9600
    Serial2.begin(9600);
	// assign default speed
	_speed = 25;
	}

	//public
			bool ALIBEMotor::goForward(){
				byte _cmd_forward[4]= {128, 0, 1 ,_speed};
				_writeMotorCommand(_cmd_forward);
			}
			bool ALIBEMotor::goBackward(){
				byte _cmd_backward[4]= {128, 0, 0 ,_speed};			
				_writeMotorCommand(_cmd_backward);
			}
			bool ALIBEMotor::Stop(){
				byte _cmd_stop[4]= {128, 0, 1 ,0};	
				_writeMotorCommand(_cmd_stop);
			}
			bool ALIBEMotor::setSpeed(byte _newSpeed){
				_speed=_newSpeed;
			}
			byte ALIBEMotor::getSpeed(){
				return _speed;
			}
			
	//private
			bool ALIBEMotor::_writeMotorCommand(byte _cmd[]){
				// write the command array of 4 bytes long
				Serial2.write(_cmd, 4);
			}